package utils.test.img;

import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import javax.imageio.ImageIO;

import com.jhlabs.image.GaussianFilter;
import com.jhlabs.image.ScaleFilter;
import com.sun.jimi.core.Jimi;
import com.sun.jimi.core.JimiException;
import com.sun.jimi.core.JimiImage;
import com.sun.jimi.core.encoder.jpg.JPGEncoder;
import com.sun.jimi.core.options.JPGOptions;

/**
 * @author lion
 * @date 2016年9月15日
 */
public class TJHlabs {

	public static void main(String[] args) throws IOException, JimiException {

		BufferedImage image = ImageIO.read(new File("D:/1651.jpg_wh1200.jpg"));
		ScaleFilter filter = new ScaleFilter(image.getWidth() / 2,
				image.getHeight() / 2);
		BufferedImageOp bf = new GaussianFilter(80);
		image = filter.filter(image, null);

		// SharpenFilter sharpenFilter = new SharpenFilter();
		// sharpenFilter.setUseAlpha(true);
		// image = sharpenFilter.filter(image, null);

		JPGOptions options = new JPGOptions();
		options.setQuality(95);

		JimiImage jimiimage = Jimi.createRasterImage(image.getSource());
		jimiimage.setOptions(options);
		JPGEncoder encoder = new JPGEncoder();
		encoder.encodeImage(jimiimage, new FileOutputStream("D:/ddddddddddddddddddddddd.jpg"));

		// writer.putImage(new
		// FileOutputStream("D:/ddddddddddddddddddddddd.png"));
		// Jimi.putImage("image/jpeg", image, );

	}
}
